﻿@using LeadMaster.Helpers
@using LeadMaster.Properties
@model LeadMaster.ViewModels.ViewModelQC

@using (Html.BeginForm("Index","QC")) 
{
@Html.ValidationSummary(true)

<fieldset style="width: 400px">
<legend>Client Selection</legend>
<table style="width: 400px">
<tr>
<th style="text-align: left">@Html.Label("Select Client")</th>
<td>
    @Html.DropDownList("LeadClient" , null, new { @class="clients chosen" , style = "width:300px;" })
</td>
</tr>
<tr>
<th>@Html.Label("Select Date")</th>
<td>@Html.DropDownList("LeadDate" , null , new { @class="leaddates" , style = "width:300px; font-size: 13px; font-family: consolas;" })</td>
</tr>
</table>
<input type="hidden" id="Mode" name="Mode" value="@(Model.Mode)" />
<div style="margin-top: 10px; float: right; clear:both;">
    <input type="submit" value="Show Leads" class="bigsubmit"/>
</div>

</fieldset>
}

<a id="allleads" href="" target="_blank">
See All Leads
</a>


<script type="text/javascript">
    $(document).ready(function () {

        $(".chosen").chosen();

        $("#LeadClient").change(function () {
            $.ajax({
                type: "GET",
                url: "@(Url.Action("LoadDates","QC"))/?leadid=" + $("#LeadClient").val() + "&mode=@(Model.Mode)",
                success: function(data){
                    var ddl = $('#LeadDate');
                    ddl.empty();
                    $(data).each(function () {
                        ddl.append(
                            $('<option/>', {
                                value: this.easyDate
                            }).html(this.easyDate)
                        );
                    });
                    $("#allleads").attr("href","http://www.dunsmorecrm.co.uk/ReportServer/Pages/ReportViewer.aspx?%2fdunsmore%2fAllClientLeads&rs:Command=Render&leadid=" + $("#LeadClient").val());
                }
            });
          });

    });
</script>